<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>My JSP 'useradd.jsp' starting page</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/amazeui.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/app.css">
<link
	href="${pageContext.request.contextPath}/style/css/bootstrap.min.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath}/style/layui/css/layui.css"
	rel="stylesheet">
<script src="${pageContext.request.contextPath}/style/js/jquery.min.js"></script>
<script
	src="${pageContext.request.contextPath}/style/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/style/js/amazeui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/style/layui/layui.js"></script>
</head>

<body>
	<form id="adduserform" class="layui-form" action="#">
		<br>
		<div class="layui-form-item">
			<input type="hidden" name="userId" value="${user.userId }">
			<label class="layui-form-label">用户名</label>
			<div class="layui-input-block">
				<input type="text" name="userName" style="width:200px" required
					lay-verify="required" placeholder="请输入用户名" autocomplete="off"
					class="layui-input" value="${ user.userName}">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">密码框</label>
			<div class="layui-input-block">
				<input type="password" style="width:200px" name="userPassword" required
					lay-verify="required" placeholder="请输入密码" autocomplete="off"
					class="layui-input" value="${user.userPassword }">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">状态</label>
			<div class="layui-input-block">
				<input id="radio1" type="radio" name="userState" value=0 title="关闭">
				<input type="radio" id="radio2" name="userState" value=1 title="正常">


			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">

				<button type="button" class="btn btn-primary" id="sub">确定</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>

	</form>

</body>
<script type="text/javascript">
$(document).ready(function() {
	if(${user.userState}==1){
		$("#radio2").attr("checked","checked");
		
	}else{
		$("#radio1").attr("checked","checked");
	}
});
</script>
<script type="text/javascript">
	
	layui.use('form', function() {
		var form = layui.form;

	});
</script>
<script type="text/javascript">
	$("#sub").click(function() {
		$.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/user/edituserpro",
			data : $("#adduserform").serialize(),
			dataType : "text",
			success : function(res) {
				if (res == "error") {
					layui.use('layer', function() {
						var layer = layui.layer;
						var index = parent.layer.getFrameIndex(window.name);
						layer.alert('存在相同用户名', {
							skin : 'layui-layer-molv' //样式类名
							,
							closeBtn : 0
						}, function() {
							parent.layer.close(index);
						});
					});
				} else if (res == "success") {
					layui.use('layer', function() {
						var layer = layui.layer;
						var index = parent.layer.getFrameIndex(window.name);
						layer.alert('用户修改成功', {
							skin : 'layui-layer-molv' //样式类名
							,
							closeBtn : 0
						}, function() {
							parent.layer.close(index);
						});
					});
				} else {
					alert("用户修改失败");
				}
			},
			error : function() {
				alert("error");
			}

		});
	});
</script>
</html>
